/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/


#include "stdafx.h"
#include <pgl/core/PGLCircleMarker.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

PGL_IMPLEMENT_DYNCREATE(CPGLCircleMarker,CPGLMarker);

#ifdef _DEBUG
void CPGLCircleMarker::Dump( CDumpContext& dc ) const
{
    // call base class function first
    CPGLMarker::Dump( dc );

    // now do the stuff for our specific class
	dc << _T("--- CPGLCircleMarker") << GetID() <<_T(" ---\n");
}

void CPGLCircleMarker::AssertValid() const
{
    // call inherited AssertValid first
    CPGLMarker::AssertValid();
} 
#endif

void CPGLCircleMarker::SerializeXML(CPGLArchive& ar)
{
	static const TCHAR szTag[] = _T("CPGLCircleMarker");

	markup::CMarkupArchive& xml = *((markup::CMarkupArchive*)ar.GetMarkup());
	if(ar.IsStoring())
	{
		xml.AddChildElem(szTag);
		xml.AddChildAttrib(_T("Name"),GetName());
		xml.IntoElem();

			/////////////////////////////////////////////////////////
			// Adding base class
			CPGLMarker::SerializeXML(ar);

		xml.OutOfElem();
	}
	else
	{
		if  (!xml.FindChildElem(szTag))
				return;

		xml.IntoElem();

			/////////////////////////////////////////////////////////
			// loading base class
			CPGLMarker::SerializeXML(ar);

		xml.OutOfElem();
	}
}


CPGLCircleMarker& CPGLCircleMarker::operator = (const CPGLCircleMarker& c)
{
	if (this != &c)
	{
		this->CPGLMarker::operator =(c);

	}

	return *this;
}

void CPGLCircleMarker::PlotGfx(gfxinterface::CGfxInterface& gfx, CPGLDataPtr pDataX, CPGLDataPtr pDataY)
{
	if (!pDataX || !pDataY || !IsVisible())
		return;

	const UINT n = __min( pDataX->size(), pDataY->size());

	if (n==0)
		return;

	// drawing....
	CPGLMarker::PlotGfx(gfx, pDataX, pDataY);
	gfx.DrawCircleStrip( *pDataX, *pDataY, GetRadius(), GetLineType());
}

void CPGLCircleMarker::PlotLegendGfx(gfxinterface::CGfxInterface& gfx, float x, float y)
{
	if (!IsVisible())
		return;

	CPGLMarker::PlotLegendGfx(gfx, x,y);
	gfx.DrawCircle( x, y, GetLegendRadius(), GetLineType());
}
